<?php
//die('sua sau');
//echo "xxx";die();
@session_start();
header('Cache-control: private'); // IE 6 FIX
// always modified
@header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
// HTTP/1.1
@header('Cache-Control: no-store, no-cache, must-revalidate');
@header('Cache-Control: post-check=0, pre-check=0', false);
// HTTP/1.0
@header('Pragma: no-cache');

include 'config.php';

$url = $_SERVER['REQUEST_URI'];
$url = preg_replace('/^\//', '', $url);

$aryURL = explode('/', $url);

if (isset($aryURL[0])) {
    $controller = $aryURL[0];
}
if(isset ($aryURL[1])){
    $adminController = $aryURL[1];
}

//$controller = 'admin';
if (get_magic_quotes_gpc ()) {

    function stripslashes_deep($value) {
        $value = is_array($value) ?
                array_map('stripslashes_deep', $value) :
                stripslashes($value);

        return $value;
    }

    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
//CONTROLLER
if ($controller == false || $controller != 'admin') {
    include myController_class;
    $objController = new MyControllers($aryConfigDB, $aryConfigs);
    $objController->setParamsByUrl($aryURL);
    if ($controller == false || $controller == 'Home') {
        $objController->def();
    } else {
        $objController->$controller();
    }
}  elseif ($controller && $controller == 'admin') {
    include adminController_class;
    $objAdmin = new AdminControllers($aryConfigDB, $aryConfigs);
    $objAdmin->setParamsByUrl($aryURL);
    if($adminController == false){
        $objAdmin->def();
    }else{
        $objAdmin->$adminController();
    }
}
?>
